//
//  LOGoodsTableViewCell.m
//  dmao-customer
//
//  Created by macbook on 2017/10/19.
//  Copyright © 2017年 秦慕乔. All rights reserved.
//

#import "LOGoodsTableViewCell.h"

@implementation LOGoodsTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _LeftType.layer.borderColor = [[UIColor colorWithHex:0xff3539]CGColor];
    _LeftType.layer.borderWidth = 1.0f;
    [_LeftType.layer setCornerRadius:3.0];
    _LeftType.layer.masksToBounds = YES;
    
    _RightType.layer.borderColor = [[UIColor colorWithHex:0xff3539]CGColor];
    _RightType.layer.borderWidth = 1.0f;
    [_RightType.layer setCornerRadius:3.0];
    _RightType.layer.masksToBounds = YES;
    
    [_ProfitLabel.layer setCornerRadius:7.0];
    _ProfitLabel.layer.masksToBounds = YES;
    
    [_toAcess addTarget:self action:@selector(AssClick:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)AssClick:(UIButton *)btn
{
    self.AssessClick();
}

- (void)cellConfigureModel:(GoodsListModel *)model
{
    if (![TXUtilsString isBlankString:model.goodsImg]) {
        [_IconImg sd_setImageWithURL:[NSURL URLWithString:[Utils getImaSting:model.goodsImg]] placeholderImage:[UIImage imageNamed:@"NoStore"] options:SDWebImageRetryFailed];
    }else{
        [_IconImg setImage:[UIImage imageNamed:@"NoStore"]];
    }
    
    _GoodsName.text = [NSString stringWithFormat:@"%@", model.goodsName];
    if ([model.brandId integerValue] > 0 && [model.isFreeShipping integerValue] > 0) {
        _LeftType.hidden = NO;
        _RightType.hidden = NO;
    }
    if ([model.brandId integerValue] > 0 && [model.isFreeShipping integerValue] <= 0) {
        _LeftType.hidden = NO;
        _RightType.hidden = YES;
    }
    if ([model.brandId integerValue] <= 0 && [model.isFreeShipping integerValue] > 0) {
        _LeftType.text = @"包邮";
        _RightType.hidden = YES;
    }
    if ([model.brandId integerValue] <= 0 && [model.isFreeShipping integerValue] <= 0) {
        _LeftType.hidden = YES;
        _RightType.hidden = YES;
    }
    
    if ([model.shopPrice floatValue]) {
        _PriceLabel.text = [NSString stringWithFormat:@"￥%.2f", [model.shopPrice floatValue]];
    }else{
        _PriceLabel.text = [NSString stringWithFormat:@"￥%.2f", [model.goodsPrice floatValue]];
    }
    
    _ProfitLabel.text = [NSString stringWithFormat:@" 分润点%.2f ", [model.goods_pv floatValue]];
    _SaleLabel.text = [NSString stringWithFormat:@"最近销量:%@", model.saleNum];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
